package stu.aistar.day03;

public class ParamDemo {
    public static void main(String[] args) {
        //基本类型采用值传递
        //将a,b变量中保存的具体的值拷贝一份赋值给了方法参数中的那俩个变量m,n
        //原文件 -> 副本
        int a = 10;
        int b = 20;
        change(a,b);
        System.out.println("main-a:"+a);//10
        System.out.println("main-b:"+b);//20

        //对象类型采用的是地址传递/引用传递
        int[] arr = {1,2,3};

        add(arr);

        System.out.println("main->:"+arr[1]);//100

        //比较特殊的是String类型[虽然是一个对象类型,但是具备基本类型传递的特点]
        String s = new String("good");
        add(s);
        System.out.println("main-str:"+s);
    }

    private static void add(String k){
        k+=" world";
        System.out.println("add-str:"+k);
    }

    private static void add(int[] arr) {
        arr[1] = 100;
        System.out.println("add->"+arr[1]);//100
    }

    private static void change(int m, int n) {
        m = m^n;
        n = m^n;
        m = m^n;
        System.out.println("change-m:"+m);//20
        System.out.println("change-n:"+n);//10
    }

}
